from bittensor.core.chain_data.metagraph_info import process_nested, _chr_str


def test_process_nested():
    """Tests process_nested function."""
    # Preps
    data = (
        None,
        {
            "name": (
                89,
                117,
                109,
                97,
                44,
                32,
                97,
                32,
                68,
                67,
                71,
                32,
                67,
                111,
                109,
                112,
                97,
                110,
                121,
            ),
            "url": (
                104,
                116,
                116,
                112,
                115,
                58,
                47,
                47,
                121,
                117,
                109,
                97,
                97,
                105,
                46,
                99,
                111,
                109,
                47,
            ),
            "github_repo": (),
            "image": (
                104,
                116,
                116,
                112,
                115,
                58,
                47,
                47,
                116,
                105,
                110,
                121,
                117,
                114,
                108,
                46,
                99,
                111,
                109,
                47,
                50,
                121,
                121,
                120,
                100,
                106,
                98,
                112,
            ),
            "discord": (),
            "description": (
                89,
                117,
                109,
                97,
                32,
                112,
                111,
                119,
                101,
                114,
                115,
                32,
                116,
                114,
                97,
                110,
                115,
                102,
                111,
                114,
                109,
                97,
                116,
                105,
                118,
                101,
                32,
                112,
                114,
                111,
                106,
                101,
                99,
                116,
                115,
                32,
                111,
                110,
                32,
                66,
                105,
                116,
                116,
                101,
                110,
                115,
                111,
                114,
                46,
            ),
            "additional": (),
        },
        None,
    )
    expected_result = [
        None,
        {
            "additional": "",
            "description": "Yuma powers transformative projects on Bittensor.",
            "discord": "",
            "github_repo": "",
            "image": "https://tinyurl.com/2yyxdjbp",
            "name": "Yuma, a DCG Company",
            "url": "https://yumaai.com/",
        },
        None,
    ]

    # Call
    result = process_nested(data, _chr_str)

    # Asserts
    assert result == expected_result
